﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lwm.x10c.Intermediate.Instructions
{
    public abstract class Instruction
    {
        public Operand Op1 { get; set; }
        public Operand Op2 { get; set; }
        public Operand Result { get; set; }

        public virtual string DumpName { get { return "?"; } }
        public virtual string NiceName { get { return "?"; } }
        public virtual bool Op1Used { get { return false; } }
        public virtual bool Op2Used { get { return false; } }

        public virtual void Dump(StringBuilder sb)
        {
            sb.Append(this.DumpName + " ");

            this.Result.Dump(sb);

            if (this.Op1Used)
            {
                sb.Append(", ");
                this.Op1.Dump(sb);
            }

            if (this.Op2Used)
            {
                sb.Append(", ");
                this.Op2.Dump(sb);
            }
        }
    }
}
